use "${datadir_nmg}\2004 to 2017 H2.dta", replace

keep if year > 2013 // no expectations question before 2014

drop if year == 2014 & half == 1 // no pcode before 2014H2


*--- Match with lookup
merge m:1 pcode using "${datadir}\la_outer_postcode_lookup", ///
	keep(1 3)

keep year half ///
	localauthority* region age age_grp fihhyr2 fihhyr2_m /// 
	hpexp1 tenure // variable of interest

	
*--- prepare date for matching house price indices
gen datem = ym(year,9) if half == 2
replace datem = ym(year,4) if half == 1

drop if year == 2017 & half == 2 // no price data for that period

gen fractionpositive 	= (hpexp1>5) if hpexp1 >= 0 // exclude "Don't know"
gen fraction5orhigher 	= (hpexp1>6) if hpexp1 >= 0 // exclude "Don't know"		

save "${datadir_nmg}\nmg_la.dta", replace
